package com.gusti.admincasa.client.ui;

import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.UIManager;

import com.gusti.admincasa.client.dto.MessageDto;
import com.gusti.admincasa.client.util.Debug;

/**
 * 
 * @author gusti
 *
 */
public class MessageView extends JFrame {

	private static final long serialVersionUID = 5091473340558610628L;

	public MessageView( MessageDto messageDto ) {

		try {
			UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
		} catch ( Exception e ) {
			Debug.error( e );
		}

		Color color;

		JTextArea text = new JTextArea( messageDto.getMessage() );
		text.setBounds( 10, 10, 325, 210 );
		text.setEditable( false );
		add( text );

		JButton responseButton = new JButton( "Responder" );
		responseButton.setBounds( 80, 230, 85, 25 );
		responseButton.addActionListener( new ActionListener() {
			@Override
			public void actionPerformed( ActionEvent e ) {
				//closeMessageView();
			}
		} );
		responseButton.setEnabled(false);
		add( responseButton );

		JButton closeButton = new JButton( "Cerrar" );
		closeButton.setBounds( 175, 230, 85, 25 );
		closeButton.addActionListener( new ActionListener() {
			@Override
			public void actionPerformed( ActionEvent e ) {
				closeMessageView();
			}
		} );
		add( closeButton );

//		color = new Color( 245, 245, 245 );
		color = new Color( 220, 220, 220 );
//		color = new Color( 176, 196, 222 );
		JPanel panel = new JPanel();
		panel.setBackground( color );
		add( panel );

		setTitle( "Nuevo mensaje de: " + messageDto.getSenderUserName() );
		setSize( 350, 290 );
		setVisible( true );
		setAlwaysOnTop( true );
		setLocationRelativeTo( null );
		setDefaultCloseOperation( HIDE_ON_CLOSE );
		setResizable( false );
	}

	private void closeMessageView() {
		setVisible( false );
	}

}
